/**
 * 此文件用于查询HTML源码
 */
import superagent from "superagent";
import fs from "fs";
import path from "path";

interface Info {
  name: string;
  url: string;
}

class Crawler {
  private url = "https://movie.douban.com/top250";

  async getRawHtml() {
    const result = await superagent.get(this.url);
    return result.text;
  }

  storeFile(data: string){
    const filePath = path.resolve (__dirname , '../data/get.html')
    fs.writeFileSync(filePath , data)
  }

  async initSpiderProcess() {
    const html = await this.getRawHtml();

    this.storeFile(html);
  }

  constructor() {
    this.initSpiderProcess();
  }
}

const crawler = new Crawler();